package com.rightsidetech.mall.dto.request;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

@Data
public class CommoditySaveReq implements Serializable {

    @ApiModelProperty(value = "商品基础id",required = true)
    @NotNull(message = "商品基础id不可为空")
    @Min(value = 1,message = "id不可小于1")
    private Long mallBaseId;

    @ApiModelProperty(value = "是否支持依旧换新 0-支持 1-不支持",required = true)
    @NotNull(message = "是否支持依旧换新不可为空")
    @Range(min = 0,max = 1,message = "是否支持以旧换新类型只有0或1")
    private Byte isInNew;

    @ApiModelProperty(value = "商品封面图",required = true)
    @NotBlank(message = "商品封面图不可为空")
    @Pattern(regexp = "^http://.*|https://.*",message = "图片应该是一个url地址")
    private String cover;

    @ApiModelProperty("以旧换新价格")
    @Range(min = 0,max = 999999999999L,message = "以旧换新价格超出最大范围、或不能为负数")
    private BigDecimal inNewPrice;

    @ApiModelProperty(value = "商品图片",required = true)
    @NotEmpty(message = "商品图片不可为空")
    @Size(max = 5,message = "商品图片最多为5张")
    private List<@Pattern(regexp = "^http://.*|https://.*",message = "图片应该是一个url地址")String> commodityPicture;

    @ApiModelProperty(value = "商品详情图片",required = true)
    @NotEmpty(message = "商品图片不可为空")
    @Size(max = 10,message = "商品详情图片最多为10张")
    private List<@Pattern(regexp = "^http://.*|https://.*",message = "图片应该是一个url地址")String> commodityDetailPicture;

    @ApiModelProperty(value = "商品价格",required = true)
    @NotNull(message = "商品价格不可为空")
    @Range(min = 0,max = 999999999999L,message = "商品价格价格超出最大范围、或不能为负数")
    private BigDecimal price;

    @ApiModelProperty(value = "划线价",required = true)
    @NotNull(message = "划线价不可为空")
    @Range(min = 0,max = 999999999999L,message = "划线价价格超出最大范围、或不能为负数")
    private BigDecimal underlinedPrice;

    @ApiModelProperty("规格明细")
    private List<CommoditySaveSpecsReq> specsList;
}
